home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / des_crypt.h < prev    next >
C/C++ Source or Header  |  1990-01-22  |  2KB  |  64 lines

  1. /*
  2.  * @(#)des_crypt.h    1.1 88/04/01 4.0NFSSRC SMI;    from 1.4 88/02/08 (C) 1986 SMI
  3.  *
  4.  * des_crypt.h, des library routine interface
  5.  * Copyright (C) 1986, Sun Microsystems, Inc.
  6.  */
  7.  
  8. #define DES_MAXDATA 8192    /* max bytes encrypted in one call */
  9. #define DES_DIRMASK (1 << 0)
  10. #define DES_ENCRYPT (0*DES_DIRMASK)    /* Encrypt */
  11. #define DES_DECRYPT (1*DES_DIRMASK)    /* Decrypt */
  12.  
  13.  
  14. #define DES_DEVMASK (1 << 1)
  15. #define    DES_HW (0*DES_DEVMASK)    /* Use hardware device */ 
  16. #define DES_SW (1*DES_DEVMASK)    /* Use software device */
  17.  
  18.  
  19. #define DESERR_NONE 0    /* succeeded */
  20. #define DESERR_NOHWDEVICE 1    /* succeeded, but hw device not available */
  21. #define DESERR_HWERROR 2    /* failed, hardware/driver error */
  22. #define DESERR_BADPARAM 3    /* failed, bad parameter to call */
  23.  
  24. #define DES_FAILED(err) \
  25.     ((err) > DESERR_NOHWDEVICE)
  26.  
  27. /*
  28.  * cbc_crypt()
  29.  * ecb_crypt()
  30.  *
  31.  * Encrypt (or decrypt) len bytes of a buffer buf.
  32.  * The length must be a multiple of eight.
  33.  * The key should have odd parity in the low bit of each byte.
  34.  * ivec is the input vector, and is updated to the new one (cbc only).
  35.  * The mode is created by oring together the appropriate parameters.
  36.  * DESERR_NOHWDEVICE is returned if DES_HW was specified but
  37.  * there was no hardware to do it on (the data will still be
  38.  * encrypted though, in software).
  39.  */
  40.  
  41.  
  42. /*
  43.  * Cipher Block Chaining mode
  44.  */
  45. int cbc_crypt(char *key, char *buf, 
  46.             unsigned int len, unsigned int mode, char *ivec); 
  47.  
  48. /*
  49.  * Electronic Code Book mode
  50.  */
  51. int ecb_crypt(char *key, char *buf, 
  52.             unsigned int len, unsigned int mode); 
  53.  
  54. #ifndef KERNEL
  55. /* 
  56.  * Set des parity for a key.
  57.  * DES parity is odd and in the low bit of each byte
  58.  */
  59. void
  60. des_setparity(/* key */); /*
  61.     char *key;    
  62. */
  63. #endif
  64.